<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="css/WdatePicker.css" rel="stylesheet" type="text/css" />
<link href="css/select.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.idTabs.min.js"></script>
<script type="text/javascript" src="js/select-ui.min.js"></script>
<script type="text/javascript" src="js/WdatePicker.js"></script>

    <script type="text/javascript">
        $(document).ready(function(e) {
            $(".select1").uedSelect({
                width : 345
            });
            $(".select2").uedSelect({
                width : 167
            });
            $(".select3").uedSelect({
                width : 100
            });
        });
    </script>

</head>

<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">表单</a></li>
    </ul>
    </div>

    <div class="formbody">

    <div class="formtitle"><span>客户信息</span></div>

    <ul class="forminfo">
<?php
    require '../lib/db.php';
    $cus_id = $_GET['id'];
    $sql = "select * from mf_customer where cus_id=".$cus_id;
    $data = db_exec_query($sql);
    foreach($data as $v){
?>
<form id="form1">
    <li><label style="width:18px;"><b>*</b></label><label>客户全称</label><input name="cus_fname" id="cus_fname" type="text" class="dfinput" value="<?php echo $v['cus_fname'];?>" /><i></i></li>
    <li><label style="width:18px;"><b>*</b></label><label>客户简称</label><input name="cus_aname" id="cus_aname" type="text" class="dfinput" value="<?php echo $v['cus_aname'];?>" /><i></i></li>
    <li><label style="width:18px;"><b>*</b></label><label>客户分类</label><cite><input name="cus_cate"  type="radio" value="品牌" <?php if($v['cus_cate']=='品牌'){echo 'checked=checked';}?> />品牌&nbsp;&nbsp;&nbsp;&nbsp;<input name="cus_cate" type="radio" value="SCP" <?php if($v['cus_cate']=='SCP'){echo 'checked=checked';}?> />SCP</cite></li>
    <li><label style="width:18px;"><b>*</b></label><label>所属区域</label>
        <div class="vocation">
            <select class="select2" name='cus_area' id="cus_area">
                <option value='华中地区' <?php if($v['cus_area']=='华中地区'){echo 'checked=checked';}?>>华中地区</option>
                <option value='华南地区' <?php if($v['cus_area']=='华南地区'){echo 'checked=checked';}?>>华南地区</option>
                <option value='华北地区' <?php if($v['cus_area']=='华北地区'){echo 'checked=checked';}?>>华北地区</option>
            </select>
        </div>
    </li>
    <li></li>
    <li id='province' style="display:yes;"><label style="width:18px;"><b>*</b></label><label>省市<b>*</b></label><input  name="cus_province" id="cus_province" type="text" value="<?php echo $v['cus_province']?>" class="dfinput" />
    <li id="provinceEdit" style="display:none;"><label style="width:18px;"><b>*</b></label><label>省市</label>
        <div class="vocation"> <select class="select3" id="s_province" name="s_province"></select> </div> 
        <div class="vocation"><select class="select3" id="s_city" name="s_city" ></select> </div> 
        <div class="vocation"><select class="select3" id="s_county" name="s_county"></select></div>
        <script class="resources library" src="js/area.js" type="text/javascript"></script>

        <script type="text/javascript">_init_area();</script>

        <div id="show"></div>
    </li>
            <script>
                $('#cus_province').focus(function(){
                    $('#province').attr('style','display:none;');
                    $('#provinceEdit').attr('style','display:yes;');
                })


            </script>
    <li><label style="width:18px;"><b>*</b></label><label>地址</label><input name="cus_address" id="cus_address" type="text" class="dfinput" value="<?php echo $v['cus_address'];?>" /><i></i></li>
    <li><label style="width:18px;"><b>*</b></label><label>负责人</label><input name="cus_linkman" id="cus_linkman" type="text" class="dfinput"  value="<?php echo $v['cus_linkman'];?>" placeholder="只能填写一个" /><i></i></li>
    <li><label style="width:18px;"><b>*</b></label><label>手机</label><input name="cus_phone" id="cus_phone" type="text" class="dfinput" value="<?php echo $v['cus_phone'];?>" placeholder="只能填写一个，用于短信提醒功能" /></li>
    <li><label style="width:18px;"><b></b></label><label>身份证号</label><input name="cus_identity_num" id="cus_identity_num" type="text" class="dfinput" value="<?php echo $v['cus_identity_num'];?>" placeholder="负责人身份证号" /></li>
    <script>
        $('#cus_identity_num').blur(function(){
            //获取输入身份证号码
            var UUserCard = $(this).val();
            //获取出生日期
            var birthday = UUserCard.substring(6, 10) + "-" + UUserCard.substring(10, 12) + "-" + UUserCard.substring(12, 14);
            $('#cus_birthday').val(birthday);
            //获取性别
            if (parseInt(UUserCard.substr(16, 1)) % 2 == 1) {
                $('#cus_sex_man').attr("checked","checked");
            } else {
                $('#cus_sex_woman').attr("checked","checked");
            }

        })
        </script>
    <li><label style="width:18px;"><b></b></label><label>复印件</label><cite><input name="cus_iscopy"  type="radio" value="1" <?php if($v['cus_iscopy']==1){echo 'checked=checked';}?> />有 &nbsp;&nbsp;&nbsp;&nbsp;<input name="cus_iscopy"  type="radio" value="0"  <?php if($v['cus_iscopy']==0){echo 'checked=checked';}?>  />无 </cite></li>
    <li><label style="width:18px;"><b>*</b></label><label>性别</label><cite><input name="cus_sex"  id="cus_sex_man" type="radio" value="0" <?php if($v['cus_sex']==0){echo 'checked=checked';}?> />男&nbsp;&nbsp;&nbsp;&nbsp;<input name="cus_sex" id="cus_sex_woman" type="radio" value="1" <?php if($v['cus_sex']==1){echo 'checked=checked';}?> />女</cite></li>
    <li><label style="width:18px;"><b></b></label><label>生日</label><input name="cus_birthday" id="cus_birthday" type="text" class="dfinput" value="<?php echo $v['cus_birthday'];?>" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"/></li>
    <li><label style="width:18px;"><b>*</b></label><label>客户代码</label><input name="cus_number" id="cus_number" value="<?php echo $v['cus_number'];?>" type="text" class="dfinput" /></li>
    <li><label style="width:18px;"><b></b></label><label>EMAIL</label><input name="cus_email" id="cus_email" type="text" value="<?php echo $v['cus_email'];?>" class="dfinput" /></li>
    <li><label style="width:18px;"><b></b></label><label>公司电话</label><input name="cus_tel" id="cus_tel" type="text" class="dfinput" value="<?php echo $v['cus_tel'];?>" /></li>
    <li><label style="width:18px;"><b></b></label><label>公司传真</label><input name="cus_fax" id="cus_fax" type="text" class="dfinput" value="<?php echo $v['cus_fax'];?>" /></li>
    <li><label style="width:18px;"><b></b></label><label>获取三证</label><cite><input name="cus_cert[]"  type="checkbox" value="营业执照" <?php if(strstr($v['cus_cert'],'营业执照')){echo 'checked=checked';}?> />营业执照　
            <input name="cus_cert[]" value="税务登记证" type="checkbox" <?php if(strstr($v['cus_cert'],'税务登记证')){echo 'checked=checked';}?> />税务登记证　
            <input name="cus_cert[]"  value='组织机构代码证' type="checkbox"  <?php if(strstr($v['cus_cert'],'组织机构代码证')){echo 'checked=checked';}?> />组织机构代码证　
        </cite>
    </li>
    <li><label style="width:350px;">以上联系人是否已经获取过公司/负责人签署的<委托书>：</label><cite><input name="cus_isget"  type="radio" value='1' <?php if($v['cus_isget']==1){echo 'checked=checked';}?> />是&nbsp;&nbsp;&nbsp;&nbsp;<input name="cus_isget" type="radio" value="0" <?php if($v['cus_isget']==0){echo 'checked=checked';}?> />否</cite></li>
    <li><label style="width:18px;"><b>*</b></label>
        <label style="width:86px;">　　业务人员 :</label>
        <label style="width:180px;">
            <div class="vocation">
                <select class="select3" name='cus_business_p' id="cus_business_p">
                    <option value='未选择'>请选择</option>
                    <option value='华南地区'>华南地区</option>
                    <option value='华北地区'>华北地区</option>
                </select>
            </div>
        </label>
        <label style="width:65px;">业务经理 :</label>
        <label style="width:180px;">
            <div class="vocation">
                <select class="select3" name='cus_business_m' id="cus_business_m">
                    <option value='未选择'>请选择</option>
                    <option value='华南地区'>华南地区</option>
                    <option value='华北地区'>华北地区</option>
                </select>
            </div>
        </label>
        <label style="width:65px;">客服部 :</label>
        <label style="width:180px;">
            <div class="vocation">
                <select class="select3" name='cus_service' id="cus_service">
                    <option value='未选择'>请选择</option>
                    <option value='华南地区'>华南地区</option>
                    <option value='华北地区'>华北地区</option>
                </select>
            </div>
        </label>
    </li>
    <li><label style="width:18px;"><b></b></label><label>备注</label><textarea name="cus_remark" cols="" rows="" class="textinput"><?php echo $v['cus_remark'];?></textarea></li>
    <li><input name="" type="button" id='btn' class="btn" value="保存修改"/>
        <label style="width:18px;"><b></b></label><label>&nbsp;</label><input style="margin-left:20px;" name="" type="button" id='btn2' class="btn" value="返回"/></li>
    </ul>
    </div>
<?php }?>
    </form>
</body>
<script type="text/javascript" src="js/WdatePicker.js"></script>
</html>
<script>

    $(function(){
        $('#btn').bind('click',function(){
            /*if(!beforeSubmit()){
                return;
            }*/
            $.ajax({
                type:"post",
                data:{'infos':$('#form1').serialize()
                },
                url:"../api/customer.php?action=edit&id=<?php echo $v['cus_id'];?>",
                success:function(result){
                    if(result){
                        alert('修改成功');
                        window.location.href = "./cuslist.php";
                    }else{
                        alert('修改失败');
                    }
                },
                error:function(){
                    alert("提交错误");
                }
            });
        });
        $('#btn2').bind('click',function(){
            window.location.href='./cuslist.php';
        });

    })
</script>
<!--省市联动js-->
<script type="text/javascript">
    var Gid  = document.getElementById ;
    var showArea = function(){
        Gid('show').innerHTML = "<h3>省" + Gid('s_province').value + " - 市" +
        Gid('s_city').value + " - 县/区" +
        Gid('s_county').value + "</h3>"
    }
    Gid('s_county').setAttribute('onchange','showArea()');
</script>
<script>
    function beforeSubmit(){
        if($('#cus_name').val()==''){
            alert('用户名不能为空！');
            $('#cus_name').focus();
            return false;
        }
        if($('#cus_linkman').val()==''){
            alert('联系人不能为空！');
            $('#cus_linkman').focus();
            return false;
        }

        if($('#cus_birthday').val()==''){
            alert('生日不能为空！');
            return false;
        }
        if($('#cus_address').val()==''){
            alert('地址不能为空！');
            $('#cus_address').focus();
            return false;
        }
        if($('#cus_phone').val()==''){
            alert('手机号不能为空！');
            $('#cus_phone').focus();
            return false;
        }
        if($('#cus_phone').val().length != 11){
            alert('请输入11位手机号');
            $('#cus_phone').focus();
            return false;
        }
        if($('#cus_identity_num').val()==''){
            alert('身份证号码不能为空！');
            $('#cus_identity_num').focus();
            return false;
        }
        if($('#cus_card_number').val()==''){
            alert('卡号不能为空！');
            $('#cus_card_number').focus();
            return false;
        }
        return true;
    }
</script>